|
|
|
|
|
|
|
The Z-Order algorithm takes the opposite approach. It draws the areas in order from back to front. When drawn in this order, an area can obscure only an area that has been drawn before it. When it draws an area, the program fills it so that it covers up any lines that it should obscure. |
|
|
|
|
|
|
|
|
The following code shows how a program can draw the areas that make up a surface in the correct order if the center of projection lies between the positive X and Z axes. |
|
|
|
 |
|
|
|
|
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function Polygon Lib "gdi32" ( _
ByVal hdc As Long, lpPoint As POINTAPI, _
ByVal nCount As Long) As Long
' Draw the transformed points on a PictureBox. Public Sub Draw(ByVal pic As Object)
Dim i As Integer
Dim j As Integer
Dim api_points(1 To 4) As POINTAPI
On Error Resume Next
' See if we should fill the "rectangles." If RemoveHidden Then
pic.FillStyle = vbFSSolid
pic.FillColor = vbWhite
Else
pic.FillStyle = vbFSTransparent
End If
' Draw the "rectangles." For i = 1 To NumX - 1
For j = 1 To NumZ - 1 ' Load the POINTAPI array. With api_points(1)
.X = points(i, j).trans(1)
.Y = points(i, j).trans(2)
End With
With api_points(2)
.X = points(i + 1, j).trans(1)
.Y = points(i + 1, j).trans(2)
End With
With api_points(3)
.X = points(i + 1, j + 1).trans(1)
.Y = points(i + 1, j + 1).trans(2)
End With
With api_points(4)
.X = points(i, j + 1).trans(1)
.Y = points(i, j + 1).trans(2) |
|
|
|
|
|